~ chicken-core (chicken-5) /manual/Module (chicken continuation)
Trap1[[tags: manual]]
2[[toc:]]
3
4== Module (chicken continuation)
5
6This module provides a more powerful interface for continuations than that
7provided by {{call/cc}}.
8
9More information about this continuation API can be found in the paper
10[[http://www.iro.umontreal.ca/~feeley/papers/FeeleySW01.pdf|A Better
11API for First-Class Continuations]] by Marc Feeley.
12
13=== Continuations API
14
15==== continuation-capture
16
17<procedure>(continuation-capture PROCEDURE)</procedure>
18
19Creates a continuation object representing the current continuation and
20tail-calls {{PROCEDURE}} with this continuation as the single argument.
21
22
23==== continuation?
24
25<procedure>(continuation? X)</procedure>
26
27Returns {{#t}} if {{X}} is a continuation object, or {{#f}} otherwise. Please
28note that this applies only to continuations created by the Continuation API,
29but not by call/cc, i.e.: {{(call-with-current-continuation continuation?)}}
30returns {{#f}}, whereas {{(continuation-capture continuation?)}} returns
31{{#t}}.
32
33
34==== continuation-graft
35
36<procedure>(continuation-graft CONT THUNK)</procedure>
37
38Calls the procedure {{THUNK}} with no arguments and the implicit continuation
39{{CONT}}.
40
41
42==== continuation-return
43
44<procedure>(continuation-return CONT VALUE ...)</procedure>
45
46Returns the value(s) to the continuation {{CONT}}. {{continuation-return}} could
47be implemented like this:
48
49<enscript highlight=scheme>
50(define (continuation-return k . vals)
51 (continuation-graft
52 k
53 (lambda () (apply values vals))))
54</enscript>
55
56
57----
58Previous: [[Module (chicken condition)]]
59
60Next: [[Module (chicken csi)]]